<?php
/**
 * 作者：亿泽
 * QQ：1260435972
 * 交流群：557649112
 * 日期：2022/03/31
 * 项目名称：亿泽不用验证系统
 * 项目说明：请勿进行违法用途，当您在使用本项目中的任何源代码时默认同意作者的观点！
 * 观点：
 * 1.禁止将本系统使用于违法违规用途。
 * 2.禁止将本系统使用包含但不限于 灰色产业/进行灰色产业的机器人插件/框架。
 * 3.禁止进行商业性质的二创二开，仅授权免费个人使用
 * 4.本系统为免费/全开源项目，禁止进行任何商业活动 除非 获得作者授权！
 * 感谢：
 * 1.使用了 光年 后台模板
 * 2.参考了 网络上部分代码资料
 * 3.感谢各位的使用~
 **/
require_once "../include/common.php";
require_once "header.php";
$title = '应用编辑 - 亿泽不用验证后台管理系统';
if ($islogin == 1) {
} else exit("<script>window.location.href='./login.html';</script>");
?>
<link href="js/bootstrap-datetimepicker/bootstrap-datetimepicker.min.css" rel="stylesheet">
<?php
if ($_GET['my'] == 'upstate') {
    $appid = intval ($_GET['appid']);
    $row = Db ::table ("applist") -> find ("*" , "appid = '$appid'") -> fetch ();
    if ($row == '') exit(popup ("不存在该ID，请检查或添加应用！" , 3));
    if (isset($_POST['submit'])) {
        $appname = daddslashes ($_POST['appname']);
        $appver = daddslashes ($_POST['appver']);
        $appdate = daddslashes ($_POST['appdate']);
        $appdw = daddslashes ($_POST['appdw']);
        $applog = daddslashes ($_POST['applog']);
        $appdoc = daddslashes ($_POST['appdoc']);
        $appgg = daddslashes ($_POST['appgg']);
        $appstatus = daddslashes ($_POST['appstatus']);
        $sql = "UPDATE `yz_applist` SET `name` = '$appname', `latest_version` = '$appver', `up_date` = '$appdate', `dw_link` = '$appdw', `log_link` = '$applog', `doc_link` = '$appdoc', `announcement` = '$appgg', `status` = '$appstatus' WHERE `appid` = '$appid';";
        if (Db ::table ("applist") -> rawexec ($sql) != 0) {
            popup ("修改成功！" , 2,"0","app_list.php");
        } else popup ("修改失败！" , 3);
    } else {
        ?>
        <div class="container-fluid p-t-15">
            <div class="row">
                <div class="col-lg-12">
                    <div class="card">
                        <header class="card-header">
                            <div class="card-title"><a  href="app_list.php" data-toggle="tooltip" data-original-title="返回应用列表" class="mdi mdi-reply-all"> &nbsp;</a>&nbsp;编辑应用</div>
                        </header>
                        <form action="./app_edit.php?my=upstate&appid=<?php echo $appid; ?>" method="post">
                            <div class="card-body">

                                <div class="input-group mb-3">
                                    <div class="input-group-prepend">
                                        <span class="input-group-text">应用名称</span>
                                    </div>
                                    <input type="text" class="form-control" name="appname"
                                           value="<?php echo $row['name']; ?>" placeholder="请输入应用名称">
                                </div>

                                <div class="input-group mb-3">
                                    <div class="input-group-prepend">
                                        <span class="input-group-text">最新版本</span>
                                    </div>
                                    <input type="text" class="form-control" name="appver"
                                           value="<?php echo $row['latest_version']; ?>" placeholder="请输入最新的版本，请注意格式！">
                                </div>

                                <div class="input-group mb-3">
                                    <div class="input-group-prepend">
                                        <span class="input-group-text">更新日期</span>
                                    </div>
                                    <input class="form-control" type="text" data-provide="datetimepicker" name="appdate"
                                           placeholder="请选择具体时间" value="<?php echo $row['up_date']; ?>"
                                           data-side-by-side="true"
                                           data-format="YYYY-MM-DD HH:mm:ss"/>
                                </div>

                                <div class="input-group mb-3">
                                    <div class="input-group-prepend">
                                        <span class="input-group-text">下载链接</span>
                                    </div>
                                    <input type="text" class="form-control" name="appdw"
                                           value="<?php echo $row['dw_link']; ?>"
                                           placeholder="请输入最新版的下载链接！">
                                </div>

                                <div class="input-group mb-3">
                                    <div class="input-group-prepend">
                                        <span class="input-group-text">更新日志</span>
                                    </div>
                                    <input type="text" class="form-control" name="applog"
                                           value="<?php echo $row['log_link']; ?>"
                                           placeholder="请输入更新日志！">
                                </div>

                                <div class="input-group mb-3">
                                    <div class="input-group-prepend">
                                        <span class="input-group-text">使用文档</span>
                                    </div>
                                    <input type="text" class="form-control" name="appdoc"
                                           value="<?php echo $row['doc_link']; ?>"
                                           placeholder="请输入使用文档！">
                                </div>

                                <div class="input-group-prepend mb-3">
                                    <span class="input-group-text">公告说明</span>
                                    <textarea class="form-control" name="appgg"
                                              aria-label="With textarea"><?php echo $row['announcement']; ?></textarea>
                                </div>
                                <div class="input-group mb-3">
                                    <span class="input-group-text"><input type="radio" id="status1" name="appstatus"
                                                                          value="1" <?php if ($row['status'] == 1) echo ("checked"); ?> />&nbsp;正常</span>
                                    <span class="input-group-text"><input type="radio" id="status2" name="appstatus"
                                                                          value="2"<?php if ($row['status'] == 2) echo ("checked"); ?> />&nbsp;维护</span>
                                    <span class="input-group-text"><input type="radio" id="status3" name="appstatus"
                                                                          value="0"<?php if ($row['status'] == 0) echo ("checked"); ?> />&nbsp;禁用</span>
                                </div>
                                <div class="input-group">
                                    <input class="btn btn-block btn-label btn-primary" type="submit" name="submit"
                                           value="修改">
                                </div>
                            </div>
                        </form>
                    </div>
                </div>

            </div>

        </div>
        <?php
    }
} elseif ($_GET['my'] == 'del') {
    $appid = intval ($_GET['appid']);
    $sql = "DELETE FROM yz_applist WHERE appid='$appid' limit 1";
    if (Db ::table ("applist") -> rawexec ($sql) != 0) {
        popup ("指令：删除 --> 操作成功！" , 2);
    } else popup ("指令：删除 --> 操作失败！" , 2);;
}
?>
<!--时间日期选择器-->
<script type="text/javascript" src="js/moment.js/moment.min.js"></script>
<script type="text/javascript" src="js/bootstrap-datetimepicker/bootstrap-datetimepicker.min.js"></script>
<script type="text/javascript" src="js/moment.js/locale/zh-cn.min.js"></script>


